package com.studor.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.studor.entity.Rule;
import com.studor.mapper.RuleMapper;
import com.studor.service.RuleService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class RuleServiceImpl extends ServiceImpl<RuleMapper, Rule> implements RuleService {

    @Override
    public List<Rule> getAvailableRules(String major, String gender) {
        QueryWrapper<Rule> wrapper = new QueryWrapper<>();
        wrapper.eq("major", major)
               .eq("gender", gender)
               .le("startTime", LocalDateTime.now())
               .ge("endTime", LocalDateTime.now());
        return this.list(wrapper);
    }
} 